using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Globalization;

namespace BizTalkCrossReferenceManager.UI
{
    /// <summary>
    /// Provides mapping for the @@ReferenceDataType@@ reference data item
    /// </summary>
    public class CustomerTitleReferenceMapping
    {
        /// <summary>
        /// Gets the common id related to a specific application id
        /// </summary>
        /// <param name="appInstance"></param>
        /// <param name="appID"></param>
        /// <returns></returns>
        public static string GetCommonID(string appInstance, string appID)
        {
            switch(appInstance)
            {
                case "SWIFT":
                    switch (appID)
                    {
                        case "1":
                            Trace.WriteLine("Get Common Customer Title:  SWIFT = 1, Common = Mr");
                            return "Mr";
                        case "2":
                            Trace.WriteLine("Get Common Customer Title:  SWIFT = 1, Common = Mr");
                            return "Mrs";
                        default:
                            Trace.WriteLine("Get Common Customer Title:  SWIFT = Unknown");
                            throw new ArgumentException("The appId is unknown", "appID");
                    }
                case "CMS":
                    switch (appID)
                    {
                        case "a":
                            return "Mr";
                        case "b":
                            return "Mrs";
                        default:
                            throw new ArgumentException("The appId is unknown", "appID");
                    }
                default:
                    Trace.WriteLine(string.Format(CultureInfo.InvariantCulture, "Get Common Customer Title: AppInstance {0} is unknown", appInstance));
                    throw new ArgumentException("The appInstance is unknown", "appInstance");
            }
        }
        /// <summary>
        /// Gets the common id related to a specific application id
        /// </summary>
        /// <param name="appInstance"></param>
        /// <param name="commonID"></param>
        /// <returns></returns>
        public static string GetApplicationID(string appInstance, string commonID)
        {
            switch (appInstance)
            {
                case "SWIFT":
                    switch (commonID)
                    {
                        case "Mr":
                            Trace.WriteLine("Get Application Customer Title:  SWIFT = 1, Common = Mr");
                            return "1";
                        case "Mrs":
                            Trace.WriteLine("Get Common Customer Title:  SWIFT = 2, Common = Mrs");
                            return "2";
                        default:
                            Trace.WriteLine("Get Common Customer Title:  SWIFT = Unknown");
                            throw new ArgumentException("The appId is unknown", "appID");
                    }
                case "CMS":
                    switch (appID)
                    {
                        case "a":
                            return "Mr";
                        case "b":
                            return "Mrs";
                        default:
                            throw new ArgumentException("The appId is unknown", "appID");
                    }
                default:
                    Trace.WriteLine(string.Format(CultureInfo.InvariantCulture, "Get Common Customer Title: AppInstance {0} is unknown", appInstance));
                    throw new ArgumentException("The appInstance is unknown", "appInstance");
            }
        }
        
    }
}
